<?php
/**
 * Description: 门店主页-住友说内容
 * Created by PhpStorm.
 * User: 玉坤
 * Date: 2021/11/11
 * Time: 15:34
 */

use Biz\model\store\MStoreContent;
use Biz\service\Store\StoreBasicService;
use Biz\service\Store\StoreContent;
use Doraemon\tools\ActionLog;


class TalkAboutListAction extends ActionPlugin
{
    public const USER_LEVEL = self::LEVEL_NOTHING;

    /**
     * @throws Exception
     */
    public function main()
    {
        $store_id = $this->getRequest()->getPost('store_id') ?? 0;
        $uid = $this->uid;
        //判断是否存在该门店
        $issetStatus = StoreBasicService::issetStoreById($store_id);
        if (!$store_id || !$issetStatus) {
            throw new \Exception("门店不存在！");
        }
        //住友说和设计师说
        $storeContent = new StoreContent($store_id);
        $card_list = $storeContent->hhzPagedList($uid, MStoreContent::CONTENT_MODULE_USER, 1, 3);
        $data['card_list'] = $card_list['list'] ?? [];
        $data['card_total'] = $card_list['total'] ?? '0';
        $designer_card_list = $storeContent->hhzPagedList($uid, MStoreContent::CONTENT_MODULE_DESIGNER, 1, 3);
        $data['designer_card_list'] = $designer_card_list['list'] ?? [];
        $data['designer_card_total'] = $designer_card_list['total'] ?? '0';
        $log_data['uid'] = $uid;
        $log_data['store_id'] = $store_id;
        ActionLog::log($uid, $log_data, ActionLog::STORE_HOMEPAGE_TALK_ABOUT);
        $this->setSuccess($data);

    }
}